<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	class Admin_action_model extends CI_Model{
		
		function __construct()
		{
			parent::__construct();
			$this->table = 'tan_admin_action';
		}
		
		function get($id)
		{
			return $this->db->select('*')
			  ->from($this->table)
			  ->where('id' , $id)
			  ->get()
			  ->row_array();
		}

        public function get_list($where, $page, $limit)
        {
            $this->db->select($this->table.'.*');
            $this->db->from($this->table);
            $this->db->where($where,null,false);
            $this->db->order_by("id", "desc");
            $this->db->limit($limit, $page);
            $query = $this->db->get();
            return $query->result_array();

        }
        public function get_Alist($where)
        {
            $this->db->select('DISTINCT '.$this->table.'.event_id',false);
            $this->db->from($this->table);
            $this->db->where($where,null,false);
            $this->db->order_by("id", "desc");
            $query = $this->db->get();
            return $query->result_array();

        }
        public function get_count($where)
        {
            $this->db->select('*');
            $this->db->from($this->table);
            $this->db->where($where,null,false);
            $query = $this->db->get();
            return $query->num_rows();
        }
        public function get_Acount($where)
        {
            $this->db->select('DISTINCT event_id',false);
            $this->db->from($this->table);
            $this->db->where($where,null,false);
            $query = $this->db->get();
            return $query->num_rows();
        }

		function insert($data)
		{
			$logdata = $data;
			$logdata['ip'] = $this->input->ip_address();
			$logdata['add_time'] = time();
			$this->db->insert($this->table, $logdata);
			return $this->db->affected_rows();
		}

	}